package me.a_littlesquid.origin.events;

import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.inventory.meta.ItemMeta;

public class blockplace implements Listener {
    @EventHandler
    public void onPutBlock(BlockPlaceEvent event) {
        ItemStack itemStack=event.getItemInHand();
        ItemMeta itemMeta=itemStack.getItemMeta();
        String itemname= itemMeta.getDisplayName();
        if (itemname.equalsIgnoreCase(ChatColor.GOLD+"无限方块")){
            Player player= event.getPlayer();
            PlayerInventory playerInventory= player.getInventory();
            playerInventory.remove(itemStack);
            playerInventory.setItemInMainHand(itemStack);
        }
    }
}
